<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTablePermissions extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('permissions', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('pid')->default(0)->comment('父级id');

            $table->string('name', 100)->default('')
                ->comment('权限名称');

            $table->tinyInteger('is_menu')->default(0)
                ->comment('是否为左侧菜单 0否 1是');

            $table->string('icon', 30)->nullable()->default('')->comment('图标名称');
            $table->string('route', 100)->nullable()->default('')->comment('路由地址');
            $table->tinyInteger('sort')->default(0)->comment('排序');

            $table->tinyInteger('is_disabled')->default(0)->comment('是否禁用 0否 1是');
            $table->timestamps();

            $table->index('pid');
            $table->index('is_menu');
            $table->index('is_disabled');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('permissions');
    }
}
